﻿var reseredTime = null;
var Remarks = null;
var saveBtn = null;
var backBtn = null;

$(function(){
    reseredTime = $("#reserved_time");
    remarks = $("#remarks");
    saveBtn = $("#save");
    backBtn = $("#back");

    reseredTime.next().html("*");
    remarks.next().html("*");
    reseredTime.on("focus",function(){
        validateTip(reseredTime.next(),{"color":"#666666"},"* 预约时间",false);
    }).on("blur",function(){
        if(reseredTime.val() != null){
            validateTip(reseredTime.next(),{"color":"green"},imgYes,true);
        }else{
            validateTip(reseredTime.next(),{"color":"red"},imgNo+" 预约时间",false);
        }
    });
    remarks.on("focus",function(){
        validateTip(remarks.next(),{"color":"#666666"},"* 备注",false);
    }).on("blur",function(){
        if(remarks.val() != null){
            validateTip(remarks.next(),{"color":"green"},imgYes,true);
        }else{
            validateTip(remarks.next(),{"color":"red"},imgNo+" 备注",false);
        }
    });
    saveBtn.on("click",function(){
        reseredTime.blur();
        remarks.blur();
        if(reseredTime.attr("validateStatus") == "true"
            && remarks.attr("validateStatus") == "true"){
            if(confirm("确定提交数据吗？")){
                $("#reservationForm").submit();
            }
        }
    });

    backBtn.on("click",function(){
        //alert("modify: "+referer);
        if(referer != undefined
            && null != referer
            && "" != referer
            && "null" != referer
            && referer.length > 4){
            window.location.href = referer;
        }else{
            history.back(-1);
        }
    });
});